/*
 * SingleFileImporter.java
 *
 *  created: 29.9.2011
 *  charset: UTF-8
 *  license: MIT (X11) (See LICENSE file for full license)
 */
package cz.mp.k3bg.core;

import cz.mp.k3bg.log.LoggerManager;
import cz.mp.util.FileUtils;
import cz.mp.util.StringUtils;
import java.io.File;
import java.io.IOException;
import java.util.logging.Logger;


/**
 * {@code SingleFileImporter} do zadaného adresáře zkopíruje soubor.
 * Používá se pro kopírování obrázku obálky.
 * 
 * @author Martin Pokorný
 * @version 0.1
 */
public class SingleFileImporter extends FileImporter {

    private static final boolean DEBUG = false;
    private static final Logger logger =
            LoggerManager.getLogger(SingleFileImporter.class, DEBUG);
    
    private String srcFilePath = "";
    
    // ----
    
    /**
     * 
     * @param destDir 
     */
    public SingleFileImporter(String destDir) {
        super(destDir);
    }

    /**
     * 
     * @param srcFilePath 
     */
    public void setSrcFilePath(String srcFilePath) {
        logger.fine("srcFilePath = " + srcFilePath);
        if (StringUtils.isBlank(srcFilePath)) {
            this.srcFilePath = "";
            return;
        }

        this.srcFilePath = srcFilePath;
    }

    @Override
    public void importt() throws IOException {
        logger.info("");
        String destFilePath = 
                getDestDir() + File.separator 
                + new File(srcFilePath).getName();
        
        FileUtils.copyFile(srcFilePath, destFilePath);
    }
    
}   // SingleFileImporter.java

